<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增商品库存信息')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-stock-add">
            <div class="form-group">    
                <label class="col-sm-3 control-label">商品选择：</label>
                <div class="col-sm-8">
                    <input name="goodsId" class="form-control" type="text">
                    <!--<div class="input-group">-->
                        <!--<input id="treeId" name="parentId" type="hidden" th:value="${goodsType?.id}"/>-->
                        <!--<input class="form-control" type="text" onclick="selectGoodsTypeTree()" id="treeName" readonly="true" th:value="${goodsType?.goodsTypeName}">-->
                        <!--<span class="input-group-addon"><i class="fa fa-search"></i></span>-->
                    <!--</div>-->
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">名称：</label>
                <div class="col-sm-8">
                    <input name="goodsName" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">规格：</label>
                <div class="col-sm-8">
                    <input name="goodsFormat" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">单位：</label>
                <div class="col-sm-8">
                    <input name="goodsUnit" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">单位描述：</label>
                <div class="col-sm-8">
                    <input name="goodsUnitDesc" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">安全库存：</label>
                <div class="col-sm-8">
                    <input name="safetyStock" class="form-control" type="number">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">库存数量：</label>
                <div class="col-sm-8">
                    <input name="stockNumber" class="form-control" type="number">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <textarea name="remark" class="form-control" maxlength="200"></textarea>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "store/stock"
        $("#form-stock-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-stock-add').serialize());
            }
        }


        /* 选择商品 */
        var storagePrefix = ctx + "wh/storage"
        function selectStorage1() {
            var url = storagePrefix + '/selectStorage';
            var options = {
                title: '选择库位(储位)',
                url: url,
                callBack: doSubmitStorage
            };
            $.modal.openOptions(options);
        }

        function doSubmitStorage(index, layero){
            var iframeWin = layero.find("iframe")[0].contentWindow.$.table;
            var rows = iframeWin.selectFirstColumns();//调用子页面的方法 获取ID
            if (rows.length == 0) {
                $.modal.alertWarning("请至少选择一条记录");
                return;
            }

            $('#storageId').val(rows.join())
            var storageName=iframeWin.selectColumns("storageName");//调用子页面的方法 获取ID
            $('#storageName').val(storageName)
            layer.close(index);
        }


    </script>
</body>
</html>